import router from "./router"
import Element from "element-ui";
//路由判断是否需要登录权限
router.beforeEach((to, from, next) => {
    //判断要去的路由是否需要登录权限
    if (to.matched.some(record => record.meta.requireAuth)) {
        const userInfo = sessionStorage.getItem("userInfo");
        // console.log(userInfo);
        //当前用户是否登录
        if ((userInfo == null)) {
            const errMsg = "请您登录。";
            Element.Message.error(errMsg);
            next({
                path: '/login'
            })
        } else {
            next()
        }
    } else {
        next()
    }

})